package cn.itcast.itcaststore.web.servlet.client;

import cn.itcast.itcaststore.serive.ModifyuserinfoService;
import cn.itcast.itcaststore.serive.impl.ModifyuserinfoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Auther: 万秋泊
 * @Date: 2021/11/1 16:25
 * @Description:  修改用户信息
 */
@WebServlet("/modifyuserinfoServlet")
public class ModifyuserinfoServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.获取修改页面输入的用户名与密码
        String username=request.getParameter("username");
        String password=request.getParameter("password");
       // 获取修改页面选择的性别
        String sex = request.getParameter("radiobutton");
        // 获取修改页面输入的手机号
        String phone = request.getParameter("text2");
        ModifyuserinfoService mdservice= new ModifyuserinfoServiceImpl();
        boolean flag = mdservice.updateUserInfo(username,password,sex,phone);
        if (flag){
            //修改成功，跳转到modifyUserInfosuccess.jsp
            response.sendRedirect(request.getContextPath()+"/client/modifyUserInfosuccess.jsp");
        }else {
            response.sendRedirect(request.getContextPath()+"/client/modifyUserInfosError.jsp");
        }

    }


}
